# Copyright (c) 2012 MaxMedia and Travis Warlick
# Licensed under the MIT License (see LICENSE)

class Module
  # Defines a DSL attribute accessor (or more than one)
  # 
  # @param names [*Symbol, *String] list of accessors to create
  #
  # @example Define an accessor
  #   module Foo
  #     class_dsl_attr_accessor :foo, :bar
  #   ene
  #   class Bar
  #     include Foo
  #     foo "fooey"
  #     bar foo+" foobar"
  #   end
  #   Bar.foo # => "fooey"
  #   Bar.bar # => "fooey foobar"
  def class_dsl_attr_accessor(*names)
    names.each do |name|
      class_eval <<-EOC, __FILE__, __LINE__+1
        def self.#{name}(val=nil)
          (val ? self.#{name} = val : @#{name})
        end
      EOC
    end
  end
end
